function addformtrip()
{
  $("#firstaddform").append('<div id="feature'+rowdiv+'" class="itPlg addImgPlg featureclass">'+dataform['trip']+"</div>"+'<input type="button" value="Submit" onclick="genformtrip()" class="btnGen btnCreateDay clTxtW cutTxt clBgSp2 fs04"><div class="emtGen"></div>');   
  var rownow=rowdiv;
 
 $("#feature"+rownow+' input[name="samecontactprofile[]"]').click(function() {
    
    if($(this).is(":checked"))
    {
    
    $.post(serviceinfo+'getmyuser', { select:['facebook','twitter','googleplus','email','website','phone','fax','etc'] }, function(data) {
    
    
           if(data.error.response)
         {
          alertbox(data.error.error);
         
         }else
         {
          if(data['data']['facebook'])$("#feature"+rownow+' input[name="facebook[]"]').val(data['data']['facebook']); 
          if(data['data']['twitter'])$("#feature"+rownow+' input[name="twitter[]"]').val(data['data']['twitter']); 
          if(data['data']['googleplus'])$("#feature"+rownow+' input[name="googleplus[]"]').val(data['data']['googleplus']); 
          if(data['data']['email'])$("#feature"+rownow+' input[name="email[]"]').val(data['data']['email']);
          if(data['data']['website'])$("#feature"+rownow+' input[name="website[]"]').val(data['data']['website']);
          if(data['data']['phone'])$("#feature"+rownow+' input[name="phone[]"]').val(data['data']['phone']);
          if(data['data']['fax'])$("#feature"+rownow+' input[name="fax[]"]').val(data['data']['fax']);
          if(data['data']['etc'])$("#feature"+rownow+' textarea[name="etc[]"]').val(data['data']['etc']);
         
         }
    
    
    });
    
    }
    
    
    });
 rowdiv++;
}

function genformtrip()
{

if($('input[name="startdate[]"]').val()&&$('input[name="enddate[]"]').val())
{
//console.log($('input[name="startdate[]"]').val());
//console.log($('input[name="enddate[]"]').val());
var day=getDaysBetweenDates($('input[name="startdate[]"]').val(), $('input[name="enddate[]"]').val());
//console.log(day);


var code = '<div  class="itPlg addMapPlg">\n';
code += '<div class="wrpPlg clBg5 clBd2 bdFull">\n';
code += '<div class="plgArea"></div>\n';
code += '<div class="wrpOutAtcPlg">\n';
code += '<div class="wrpAtcPlg">\n';
code += '<span class="ico icoOri icoMapPlg"></span>\n';
code += '<div class="spnAtcPlg clTxtW">\n';
code += '<span class="txtAtcPlg fs03">Map</span>\n';
code += '</div>\n';
code += '</div>\n';
code += '</div>\n';
code += '<span class="desPlg clTxt3 fs03">location of your trip.</span>\n';
code += '</div>\n';
code += '</div>';
$("#addform .addMapPlg").remove();
$("#addform").append(code);
rowdiv++;

var code="";


rowdiv++;

  $("#addform .addTripPlg").remove();
if(day+1)
{

var startdateset=$('input[name="startdate[]"]').val();
var n0=startdateset.split("/"); 
var d1 = new Date(n0[2],parseInt(n0[1],10)-1,parseInt(n0[0],10));
$("#addform .addTripPlg").remove();

for(var i=0;i<day+1;i++)
{
var n2=startdateset.split("/"); 
code += '<div id="featuretriprow-'+(i+1)+'"  class="date'+n2[2]+'-'+n2[1]+'-'+n2[0]+' itPlg addTripPlg">\n';
code += '<div class="wrpPlg clBg5 clBd2 bdFull">\n';
code += '<div class="plgArea"></div>\n';
code += '<div class="wrpOutAtcPlg">\n';
code += '<div class="wrpAtcPlg">\n';
code += '<div class="spnHdDayTrip clTxtW">\n';
code += '<span class="fs03">Day '+(i+1)+'</span><br>\n';
code += '<span class="rcmSizeAdd fs01">'+startdateset+'</span>\n';

d1.setTime(d1.getTime() +  ((i+1) * 24 * 60 * 60 * 1000));
startdateset=d1.format("dd/mm/yyyy");
code += '</div>\n';
code += '</div>\n';
code += '<div class="wrpAtcPlg slctCell">\n';
code += '<div class="spnSlctCell clTxtW">\n';
code += '<span class="fs03 myCellTrip clBd3 bdR" onclick="openpopuptrip('+(i+1)+',1)">My Post</span>\n';
code += '<span class="fs03 myFavTrip clBd3 bdR" onclick="openpopuptrip('+(i+1)+',2)">My Favorites</span>\n';
code += '<span class="fs03 newActTrip clBd3 bdR" onclick="openpopupactivity('+(i+1)+')">New Activity</span>\n';
code += '<span class="fs03 newCtntTrip" onclick="$(\'.btnAddSB.fs05.clBd2.cutTxt\').trigger(\'click\')">New Content</span>\n';
code += '</div>\n';
code += '</div>\n';
code += '</div>\n';
code += '<span class="desPlg clTxt3 fs03">Select \'Point of Interest\' for create your trip.</span>\n';
code += '</div>\n';
code += '</div>';


}

$("#addform").append(code);


}
}


}

var dateFormat = function () {
    var    token = /d{1,4}|m{1,4}|yy(?:yy)?|([HhMsTt])\1?|[LloSZ]|"[^"]*"|'[^']*'/g,
        timezone = /\b(?:[PMCEA][SDP]T|(?:Pacific|Mountain|Central|Eastern|Atlantic) (?:Standard|Daylight|Prevailing) Time|(?:GMT|UTC)(?:[-+]\d{4})?)\b/g,
        timezoneClip = /[^-+\dA-Z]/g,
        pad = function (val, len) {
            val = String(val);
            len = len || 2;
            while (val.length < len) val = "0" + val;
            return val;
        };

    // Regexes and supporting functions are cached through closure
    return function (date, mask, utc) {
        var dF = dateFormat;

        // You can't provide utc if you skip other args (use the "UTC:" mask prefix)
        if (arguments.length == 1 && Object.prototype.toString.call(date) == "[object String]" && !/\d/.test(date)) {
            mask = date;
            date = undefined;
        }

        // Passing date through Date applies Date.parse, if necessary
        date = date ? new Date(date) : new Date;
        if (isNaN(date)) throw SyntaxError("invalid date");

        mask = String(dF.masks[mask] || mask || dF.masks["default"]);

        // Allow setting the utc argument via the mask
        if (mask.slice(0, 4) == "UTC:") {
            mask = mask.slice(4);
            utc = true;
        }

        var    _ = utc ? "getUTC" : "get",
            d = date[_ + "Date"](),
            D = date[_ + "Day"](),
            m = date[_ + "Month"](),
            y = date[_ + "FullYear"](),
            H = date[_ + "Hours"](),
            M = date[_ + "Minutes"](),
            s = date[_ + "Seconds"](),
            L = date[_ + "Milliseconds"](),
            o = utc ? 0 : date.getTimezoneOffset(),
            flags = {
                d:    d,
                dd:   pad(d),
                ddd:  dF.i18n.dayNames[D],
                dddd: dF.i18n.dayNames[D + 7],
                m:    m + 1,
                mm:   pad(m + 1),
                mmm:  dF.i18n.monthNames[m],
                mmmm: dF.i18n.monthNames[m + 12],
                yy:   String(y).slice(2),
                yyyy: y,
                h:    H % 12 || 12,
                hh:   pad(H % 12 || 12),
                H:    H,
                HH:   pad(H),
                M:    M,
                MM:   pad(M),
                s:    s,
                ss:   pad(s),
                l:    pad(L, 3),
                L:    pad(L > 99 ? Math.round(L / 10) : L),
                t:    H < 12 ? "a"  : "p",
                tt:   H < 12 ? "am" : "pm",
                T:    H < 12 ? "A"  : "P",
                TT:   H < 12 ? "AM" : "PM",
                Z:    utc ? "UTC" : (String(date).match(timezone) || [""]).pop().replace(timezoneClip, ""),
                o:    (o > 0 ? "-" : "+") + pad(Math.floor(Math.abs(o) / 60) * 100 + Math.abs(o) % 60, 4),
                S:    ["th", "st", "nd", "rd"][d % 10 > 3 ? 0 : (d % 100 - d % 10 != 10) * d % 10]
            };

        return mask.replace(token, function ($0) {
            return $0 in flags ? flags[$0] : $0.slice(1, $0.length - 1);
        });
    };
}();

// Some common format strings
dateFormat.masks = {
    "default":      "ddd mmm dd yyyy HH:MM:ss",
    shortDate:      "m/d/yy",
    mediumDate:     "mmm d, yyyy",
    longDate:       "mmmm d, yyyy",
    fullDate:       "dddd, mmmm d, yyyy",
    shortTime:      "h:MM TT",
    mediumTime:     "h:MM:ss TT",
    longTime:       "h:MM:ss TT Z",
    isoDate:        "yyyy-mm-dd",
    isoTime:        "HH:MM:ss",
    isoDateTime:    "yyyy-mm-dd'T'HH:MM:ss",
    isoUtcDateTime: "UTC:yyyy-mm-dd'T'HH:MM:ss'Z'"
};

// Internationalization strings
dateFormat.i18n = {
    dayNames: [
        "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat",
        "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"
    ],
    monthNames: [
        "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec",
        "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"
    ]
};

// For convenience...
Date.prototype.format = function (mask, utc) {
    return dateFormat(this, mask, utc);
};

function getDaysBetweenDates(d0, d1) 
{

  

  var n0=d0.split("/"); 
  var n1=d1.split("/"); 
// d0=n0[2]+'-'+parseInt(n0[1],10)+'-'+parseInt(n0[0],10);
//  d1=n1[2]+'-'+parseInt(n1[1],10)+'-'+parseInt(n1[0],10);
  // Copy dates so don't mess them up
  var d1 = new Date(n0[2],parseInt(n0[1],10)-1,parseInt(n0[0],10));
  var d2 = new Date(n1[2],parseInt(n1[1],10)-1,parseInt(n1[0],10));

  
  var diff=d2-d1,sign=diff<0?-1:1,milliseconds,seconds,minutes,hours,days;
diff/=sign; // or diff=Math.abs(diff);
diff=(diff-(milliseconds=diff%1000))/1000;
diff=(diff-(seconds=diff%60))/60;
diff=(diff-(minutes=diff%60))/60;
days=(diff-(hours=diff%24))/24;

//console.info(sign===1?"Elapsed: ":"Remains: ",
//             days+" days, ",
//             hours+" hours, ",
//             minutes+" minutes, ",
//             seconds+" seconds, ",
//             milliseconds+" milliseconds.");
             
             return days;
  
  // Set to noon - avoid DST errors
 // x0.setHours(12,0,0);
  //x1.setHours(12,0,0);

  // Round to remove daylight saving errors
 // return Math.round( (x1 - x0) / msPerDay );
}
var tripidrow=0;
var setstatusnow=0;
function closepopupactivity()
{
$(".ovlPopGen.wrpAddAct").html('');
$(".ovlPopGen.wrpAddAct").fadeOut();

}                                             
function openpopuptrip(idrow,status)
{
pagemain=1;
tripidrow=idrow;

var code = '<div class="popGen posPop">\n';
code += '<div class="topGen clBd2 bdBtm">\n';
code += '<div class="wrpTtlGen">\n';
code += '<h1 class="ttlGen clTxt2 fs05 cutTxt">Select Cells</h1>\n';
code += '</div>\n';
code += '<div class="btnIco closeGen" onclick="closepopup()">\n';
code += '<span class="ico icoCloseGen"></span>\n';
code += '</div>\n';
code += '<div class="topBgGen clBg3"></div>\n';
code += '</div>\n';
code += '<div class="bodyGen clBg3">\n';
code += '<div class="bodyOutGen">\n';
code += '<div class="bodyInGen">\n';
code += '<p class="desAddGen clTxt3 fs03">You can multiple select.</p>\n';
code += '<div class="wrpSlctGenSrc">\n';
code += '<div class="slctGenSrc fs04 clTxt2">\n';
code += '<span id="tripsstatus-1" onclick="changecelldata(1)" class="spnSrcTg tgCl clSp2">My Cells</span>\n';
code += '<span class="vtcLn clTxt3">|</span>\n';
code += '<span id="tripsstatus-2" onclick="changecelldata(2)" class="spnSrcTg tgCl">My Favorites</span>\n';
code += '</div>\n';
code += '<div class="wrpOutSrchBox">\n';
code += '<div class="wrpSrchBox">\n';
code += '<input type="text" placeholder="Search" class="srchBox clBg4 fs01 clTxt3">\n';
code += '<div class="btnIco srchGen">\n';
code += '<span class="ico icoSrchGen"></span>\n';
code += '</div>\n';
code += '</div>\n';
code += '</div>\n';
code += '</div>\n';
code += '<div class="wrpFrmGen wrpFrmGenImg clBg4 clBd1 bdFull">\n';
code += '<div class="frmGenImg clearfix">\n';
code += '<button onclick="" class="btnSeeMore clTxt3 fs02">See More</button>\n';
code += '</div>\n';
code += '</div>\n';
code += '<div class="wrpBtnGen">\n';
code += '<input type="submit" onclick="savepopuptrip()" value="OK" class="btnGen clTxtW cutTxt clBgSp2 fs04">\n';
code += '<input type="button" onclick="closepopup()" value="Cancel" class="btnGen btnCncl clTxtW cutTxt clBgBt1 fs04">\n';
code += '</div>\n';
code += '</div>\n';
code += '</div>\n';
code += '</div>\n';
code += '</div>';
$(".ovlPopGen.wrpPopAddPop").html(code);
$(".ovlPopGen.wrpPopAddPop").fadeIn();

changecelldata(status);


}

var activityidset=0;

function editformtrip(datarow)
{
       addformtrip();

var rownow= rowdiv-1;
var rowgnow2=1;

    //console.log(rownow);
    if(datarow.samecontactprofile!="0")
    {
    $("#feature"+rownow+' input[name="samecontactprofile[]"]').trigger('click');
    }else
    {
    $("#feature"+rownow+' input[name="facebook[]"]').val(datarow.facebook);
    $("#feature"+rownow+' input[name="twitter[]"]').val(datarow.twitter);
    $("#feature"+rownow+' input[name="googleplus[]"]').val(datarow.googleplus);
    $("#feature"+rownow+' input[name="website[]"]').val(datarow.website);
    $("#feature"+rownow+' input[name="email[]"]').val(datarow.email);
    $("#feature"+rownow+' input[name="fax[]"]').val(datarow.fax);
    $("#feature"+rownow+' textarea[name="etc[]"]').val(datarow.etc);
    
    }
    
    //console.log(datarow);
    genformtrip();
    var code="";
    $.each(datarow['objdata'], function(keydata, valueobjdata) {
    if(Object.keys(valueobjdata).length>0)
{
var datearr=keydata.split("/");
//console.log(datearr);
var idarr=$(".date"+datearr[2]+"-"+datearr[1]+"-"+datearr[0]).attr("id").split("-"); ;
tripidrow=idarr[1];

 $.each(valueobjdata, function(keydata, valuedata2) {
 
  if(valuedata2['isactivity']=="0")
 {
 
var checkpoint=0;
var latsettrip=0;
var lngsettrip=0;
//$( ".ovlPopGen.wrpPopAddPop .activeproduct .setproducthidden" ).each(function( index ) {

//console.log("1");

setlandingproduct[rowlanding]={};
setlandingproduct[rowlanding]=valuedata2.data;

code  = '<div class="wrpInCell wrpInCellTrip w158" id="wrpInCellTrip-'+rowlanding+'" style="margin:1px">\n';
code += '<div class="ovlCellTrip w158"></div>\n';
code += '<img width="158" height="158" alt="img" src="'+setlandingproduct[rowlanding].simg.newpath+'" class="imgCell w158">\n';
code += '<div class="wrpTl wrpBtnEdtCell">\n';
code += '<div title="Remove" class="btnIco closeTl" onclick="removedatatrip('+rowlanding+')">\n';
code += '<span class="ico icoCloseTl"></span>\n';
code += '</div>\n';
code += '</div>\n';
code += '<div class="ldTtlCell ldTtlTrip fs05 clTxtCell cutTxt">'+setlandingproduct[rowlanding].title+'</div>\n';
code += '<form class="inpTimeTrip">\n';

var timesetarr=valuedata2['timeset'].split(":"); 

code += '<input type="text" alt="timeTrip-'+tripidrow+'-'+rowlanding+'" value="'+timesetarr[0]+':'+timesetarr[1]+'"  placeholder="Click for insert time." class="timeTrip clTxtW fs01">\n';
code += '</form>\n';

if(setlandingproduct[rowlanding].plugins)
{
checkpoint=0;
$.each( setlandingproduct[rowlanding].plugins, function( key, value ) {

if(value.plugname=="map")
{

checkpoint=1;
latsettrip=value.lat;
lngsettrip=value.lng;


}

});


}

if(checkpoint==1)
{
code += '<div class="pointTrip classpoint">\n';

code += '<input type="hidden" value="'+latsettrip+'" name="latsetrip[]">';
code += '<input type="hidden" value="'+lngsettrip+'" name="lngsetrip[]">';
code += '<input type="hidden" value="'+valuedata2['sproductid']+'" name="productidtrip[]">';


var lengthall=$('.plgAreaTrip .wrpInCell.wrpInCellTrip.w158 .pointTrip.classpoint').length;

code += '<span class="clTxtW fs02">'+pointData[lengthall]+'</span>\n';
code += '</div>\n';
}

code += '</div>';

if($("#featuretriprow-"+tripidrow).hasClass('ispoi'))
{


}else
{
$("#featuretriprow-"+tripidrow+' .plgArea').remove();
$("#featuretriprow-"+tripidrow+' .desPlg.clTxt3.fs03').remove();
$("#featuretriprow-"+tripidrow).addClass('ispoi');
$("#featuretriprow-"+tripidrow+' .wrpOutAtcPlg').after( '<div class="wrpPlgAreaTrip Clearfix"><div class="plgAreaTrip"></div></div>' );

}


$("#featuretriprow-"+tripidrow+' .plgAreaTrip').append(code);
rowlanding++;
//$(".ovlPopGen.wrpPopAddPop").fadeOut();

//});

 
 }else
 {
 var numsetact=rowlanding;
 //console.log(valuedata2);
code = '<div class="wrpInCell wrpInCellTrip w158 isactivity" id="wrpInCellTrip-'+numsetact+'" style="margin:1px">\n';
code += '<div class="ovlCellTrip w158"></div>\n';
code += '<img width="158" height="158" alt="img" src="'+valuedata2['simg']['newpath']+'" class="imgCell w158">\n';
code += '<div class="wrpTl wrpBtnEdtCell">\n';
code += '<div title="Remove" class="btnIco closeTl clBd3 bdBtm" onclick="removedataactivities('+numsetact+')">\n';
code += '<span class="ico icoCloseTl"></span>\n';
code += '</div>\n';
code += '<div title="Edit" class="btnIco edtCell" onclick="editactivity('+tripidrow+','+numsetact+')">\n';
code += '<span class="ico icoEdtCell"></span>\n';
code += '</div>\n';
code += '</div>\n';
code += '<div class="ldTtlCell ldTtlTrip fs05 clTxtCell cutTxt titleact">'+valuedata2['title']+'</div>\n';
code +='<textarea style="display:none" id="descriptionact-'+numsetact+'" name="descriptionact[]">'+valuedata2['description']+'</textarea>';

code +='<input name="imgmid[]" type="hidden" value="'+valuedata2['imgmid']+'">';
code +='<input name="simgmid[]" type="hidden" value="'+valuedata2['simgmid']+'">';


code += '<form class="inpTimeTrip">\n';
var timesetarr=valuedata2['timeset'].split(":");

code += '<input type="text" placeholder="Click for insert time." alt="timeTrip-'+tripidrow+'-'+numsetact+'" value="'+timesetarr[0]+':'+timesetarr[1]+'" class="timeTrip clTxtW fs01">\n';
code += '</form>\n';
code += '<div class="pointTrip classActity">\n';


var numsetdata=rownumberactnum;
rownumberactnum++;

code += '<span class="clTxtW fs02">'+numsetdata+'</span>\n';
code += '</div>\n';
 
 
 
code += '</div>';

if($("#featuretriprow-"+tripidrow).hasClass('ispoi'))
{


}else
{
$("#featuretriprow-"+tripidrow+' .plgArea').remove();
$("#featuretriprow-"+tripidrow+' .desPlg.clTxt3.fs03').remove();
$("#featuretriprow-"+tripidrow).addClass('ispoi');
$("#featuretriprow-"+tripidrow+' .wrpOutAtcPlg').after( '<div class="wrpPlgAreaTrip Clearfix"><div class="plgAreaTrip"></div></div>' );

}
$("#featuretriprow-"+tripidrow+' .plgAreaTrip').append(code);

rowlanding++;
 
 
 
 }
 
 });
 
}
    
    });

$( "#featuretriprow-"+tripidrow+' .timeTrip.clTxtW.fs01' ).datepicker( "destroy" ); 
$("#featuretriprow-"+tripidrow+' .timeTrip.clTxtW.fs01').timepicker(
   {onClose: function(dateText, inst) {

   
   var idtimetrip=$(this).attr("alt");
   var rownid=idtimetrip.split("-"); 
   changetimedata(rownid[1]);
   
    }
    
    }); 
    
    genmapdata();
    
    
//       
//       
//    $('#feature'+rownow+' .image'+rowgnow2+' .plgArea').html('<a target="_blank" href="'+datarow.img.newpath+'?t='+Math.floor((Math.random()*100000)+1)+'"><img height="360" width="640" src="'+datarow.simg.newpath+'?t='+Math.floor((Math.random()*100000)+1)+'"></a>');
//    $('#feature'+rownow+' .image'+rowgnow2+' input[name="imgmid[]"]').val(datarow.imgmid);
//    $('#feature'+rownow+' .image'+rowgnow2+' input[name="simgmid[]"]').val(datarow.simgmid);
//    $('#feature'+rownow+' input[name="detail[]"]').val(datarow.detail);   


}


function editactivity(idrow,rownowdata)
{

openpopupactivity(idrow,rownowdata);

}

function openpopupactivity(idrow,activityid)
{
tripidrow=idrow;
var title,desc,img,timedata,imgmid,simgmid;
if(activityid)
{

activityidset=activityid;
title=$("#wrpInCellTrip-"+activityidset+" .titleact").html();
desc=$("#descriptionact-"+activityidset).val();
srcimg=$("#wrpInCellTrip-"+activityidset+" .imgCell.w158").attr("src");
img='<img width="150" height="150" alt="img" src="'+srcimg+'" class="imgTn">';
timedata=$("#wrpInCellTrip-"+activityidset+' .timeTrip').val();
imgmid=$("#wrpInCellTrip-"+activityidset+' input[name="imgmid[]"]').val();
simgmid=$("#wrpInCellTrip-"+activityidset+' input[name="simgmid[]"]').val();

}else
{
activityidset=0;
title="";
desc="";
srcimg=baseinfo+'/img/dfthmbcell.jpg';
img='<img width="150" height="150" alt="img" src="'+srcimg+'" class="imgTn">';
timedata="";
imgmid="";
simgmid="";

}

var code = '<div class="popGen posPop" id="featureactivity">\n';
code += '<div class="topGen clBd2 bdBtm">\n';
code += '<div class="wrpTtlGen">\n';
code += '<h1 class="ttlGen clTxt2 fs05">Add Activity</h1>\n';
code += '</div>\n';
code += '<div class="btnIco closeGen" onclick="closepopupactivity()">\n';
code += '<span class="ico icoCloseGen"></span>\n';
code += '</div>\n';
code += '<div class="topBgGen clBg3"></div>\n';
code += '</div>\n';
code += '<div class="bodyGen clBg3">\n';
code += '<div class="bodyOutGen">\n';
code += '<div class="bodyInGen">\n';
code += '<p class="desAddGen clTxt3 fs03">Something</p>\n';
code += '<div class="bodyAddAct clBg4 clBd2 bdFull">\n';
code += '<form class="wrpFrmGen">\n';
code += '<fieldset class="wrpFrmAddAct">\n';
code += '<div class="wrpOutImgAddAct">\n';
code += '<div class="wrpTtlImgAddAct">\n';
code += '<h2 class="ttlImgAddAct clTxt2 fs03">Thumbnail</h2>\n';
code += '<p class="rcmImgAddAct clTxt3 fs01">recommended size : 600px X 600px</p>\n';
code += '</div>\n';
code += '<div class="wrpImgAddAct image1">\n';
code += '<div class="imgAddAct clBg5 clBd2 bdFull plgAreaThumbnail">\n';
code += img+'\n';
code += '</div>\n';
code += '<div class="addTnTl clBd2 bdBtm">\n';
code += '<div title="Browse" class="btnIco addImgTl clBd3 bdBtm uploadbutton">\n';
code += '<span class="ico icoAddImgTl"></span>\n';
code += '<div class="wrpUlFile">\n';
//code += '<input type="file" class="ulFile">\n';
code += '</div>\n';
code += '</div>\n';
code += '<div title="Cloud" class="btnIco addCldTl clBd3 bdBtm cloudbutton cloud1">\n';
code += '<span class="ico icoAddCldTl"></span>\n';
code += '</div>\n';
code += '<div title="Link" class="btnIco addLnkTl clBd3 bdBtm linkbutton link1">\n';
code += '<span class="ico icoAddLnkTl"></span>\n';
code += '</div>\n';
code += '<div title="Remove" class="btnIco btnRmvTl deletebutton">\n';
code += '<span class="ico icoRmvTl"></span>\n';
code += '</div>\n';
code += '</div>\n';
code += '</div>\n';
code += '</div>\n';
code += '<div class="wrpInfoAddAct">\n';
code += '<div class="wrpInpTtlAddAct">\n';
code += '<label class="lbInpAddAct fs03 clTxt2">Title</label><br>\n';
code += '<input type="text" name="titleact[]" value="'+title+'" class="inpTtlAddAct clBg5 clTxt3 fs01">\n';
code += '</div>\n';
code += '<div class="wrpInpDesAddAct">\n';
code += '<label class="lbInpAddAct fs03 clTxt2">Description</label><br>\n';
code += '<textarea maxlength="128" required="" name="descact[]" class="inpDesAddAct clBg5 clTxt3 fs01">'+desc+'</textarea>\n';
code += '</div>\n';
code += '<div class="wrpInpTimeAddAct">\n';
code += '<label class="lbInpAddAct fs03 clTxt2">Time</label><br>\n';
code += '<input type="text" value="'+timedata+'" class="inpTimeAddAct clBg5 clTxt3 fs01">\n';
code += '</div>\n';
code += '</div>\n';
code += '</fieldset>\n';
code += '</form>\n';
code += '</div>\n';
code += '<div class="wrpBtnExpnPop">\n';
code += '<input type="button" onclick="closepopupactivity()" value="Cancel" class="btnGen btnCncl clTxtW cutTxt clBgBt1 fs04">\n';
code += '<input type="submit"  value="OK" onclick="saveactivitypopup()" class="btnGen clTxtW cutTxt clBgSp2 fs04">\n';
code += '</div>\n';
code += '</div>\n';
code += '</div>\n';
code += '</div>\n';
code += '</div>';

$(".ovlPopGen.wrpAddAct").html(code);



$(".ovlPopGen.wrpAddAct").fadeIn();


  var rowgnow=1;
  
  
   var rownow='activity';
   $('#feature'+rownow+' .image'+rowgnow+' .uploadbutton').iuploader({
         'link':serviceinfo+'iupload',
         'accept':'image/*',
         'group':rowgnow,

         'type':['jpg', 'jpeg', 'png', 'gif'],
         'onUploadFinish':function(filename,filelink,setting){
         
         
         
         
         getpopupboxresize(300,300,filelink,setting['originalwidth'],setting['originalheight'],
         
         function(filename2,filelink2,width2,height2,imgmid2){
         var rowgnow2=setting['group'];
         
         $('#feature'+rownow+' .image'+rowgnow2+' .plgAreaThumbnail').html('<a target="_blank" href="'+filelink+'?t='+Math.floor((Math.random()*100000)+1)+'"><img height="150" width="150" src="'+filelink2+'?t='+Math.floor((Math.random()*100000)+1)+'"></a>');
         

         
         $('#feature'+rownow+' .image'+rowgnow2+' input[name="filelink[]"]').val(filelink);
         $('#feature'+rownow+' .image'+rowgnow2+' input[name="filelinkcrop[]"]').val(filelink2);
         
         
         $('#feature'+rownow+' .image'+rowgnow2+' input[name="fileold[]"]').val(setting.fileold);
         
         $("#width-"+setting.id).val(setting.originalwidth);
         $("#height-"+setting.id).val(setting.originalheight);
         
         
         $("#imgmid-"+setting.id).val(setting.imgmid);
         
         $("#simgmid-"+setting.id).val(imgmid2);
         
         
         $("#widthcrop-"+setting.id).val(width2);
         $("#heightcrop-"+setting.id).val(height2);
         
         closepopup(); 
         
         }
         ,setting['imgmid']
         
         );
         //alert(filename);
         }
   });
  
  
   $('#feature'+rownow+' .image'+rowgnow+' .cloudbutton').click(function() {
          //var rowgnow3=rowgnow;
          var rowgnow3=$(this).attr("class").split('cloud').pop();
        //alert("Handler for .click() called.");
          getpopupcloud(
          function(filename2,filelink2,width2,height2,imgmid2,index2){ 
          
          
         $('#feature'+rownow+' .image'+rowgnow3+' .plgAreaThumbnail').html('<a target="_blank" href="'+$('#feature'+rownow+' .image'+rowgnow3+' input[name="filelink[]"]').val()+'?t='+Math.floor((Math.random()*100000)+1)+'"><img height="150" width="150" src="'+filelink2+'?t='+Math.floor((Math.random()*100000)+1)+'"></a>');
         $('#feature'+rownow+' .image'+rowgnow3+' input[name="simgmid[]"]').val(imgmid2);
         $('#feature'+rownow+' .image'+rowgnow3+' input[name="filelinkcrop[]"]').val(filelink2);                                    
         $('#feature'+rownow+' .image'+rowgnow3+' input[name="widthcrop[]"]').val(width2);         
         $('#feature'+rownow+' .image'+rowgnow3+' input[name="heightcrop[]"]').val(height2);
         closepopup(); 

          
          },
          function(filename,filelink,width,height,imgmid,indexnow){
            
            //$('#feature'+rownow+' .royalSlider  a.rsImg').eq((rowgnow3-1)).attr("href",filelink+'?t='+Math.floor((Math.random()*100000)+1));
           // $('#feature'+rownow+' .rsSlide  img').eq((rowgnow3-1)).attr("src",filelink+'?t='+Math.floor((Math.random()*100000)+1));
            $('#feature'+rownow+' .image'+rowgnow3+' input[name="filelink[]"]').val(filelink);
            $('#feature'+rownow+' .image'+rowgnow3+' input[name="imgmid[]"]').val(imgmid);           
            $('#feature'+rownow+' .image'+rowgnow3+' input[name="width[]"]').val(width);
            $('#feature'+rownow+' .image'+rowgnow3+' input[name="height[]"]').val(height);
            

          
          }
          ,
          rowgnow
          ,300
          ,300
          
          );

   });
   
   $('#feature'+rownow+' .image'+rowgnow+' .deletebutton').click(function() {
   
   var rowgnow3=1;
   
   $('#feature'+rownow+' .image'+rowgnow3+' .plgAreaThumbnail a').remove();
   //$('#feature'+rownow+' .royalSlider  a.rsImg').eq((rowgnow3-1)).attr("href",'/images/default/noimage640x360.jpg'+'?t='+Math.floor((Math.random()*100000)+1));
  // $('#feature'+rownow+' .rsSlide  img').eq((rowgnow3-1)).attr("src",'/images/default/noimage640x360.jpg'+'?t='+Math.floor((Math.random()*100000)+1));
  // $('#feature'+rownow+' .image'+rowgnow3+' img').attr("src",'/images/default/noimage640x360.jpg'+'?t='+Math.floor((Math.random()*100000)+1));
   
   $('#feature'+rownow+' .image'+rowgnow3+' input[name="filelink[]"]').val('');
   $('#feature'+rownow+' .image'+rowgnow3+' input[name="imgmid[]"]').val('');           
   $('#feature'+rownow+' .image'+rowgnow3+' input[name="width[]"]').val('');
   $('#feature'+rownow+' .image'+rowgnow3+' input[name="height[]"]').val('');
   
   
   
    $('#feature'+rownow+' .image'+rowgnow3+' input[name="simgmid[]"]').val('');
     $('#feature'+rownow+' .image'+rowgnow3+' input[name="filelinkcrop[]"]').val('');                                    
     $('#feature'+rownow+' .image'+rowgnow3+' input[name="widthcrop[]"]').val('');         
     $('#feature'+rownow+' .image'+rowgnow3+' input[name="heightcrop[]"]').val('');
   
   });
   
   $('#feature'+rownow+' .image'+rowgnow+' .linkbutton').click(function() {
   var rowgnow3=1;
   
   
   getpopuplink(
          function(filename2,filelink2,width2,height2,imgmid2,index2){ 
          
          
         //$('#feature'+rownow+' .image'+rowgnow3+' img').attr("src",filelink2+'?t='+Math.floor((Math.random()*100000)+1));
         
         $('#feature'+rownow+' .image'+rowgnow3+' .plgAreaThumbnail').html('<a target="_blank" href="'+$('#feature'+rownow+' .image'+rowgnow3+' input[name="filelink[]"]').val()+'?t='+Math.floor((Math.random()*100000)+1)+'"><img height="150" width="150" src="'+filelink2+'?t='+Math.floor((Math.random()*100000)+1)+'"></a>');
         
         $('#feature'+rownow+' .image'+rowgnow3+' input[name="simgmid[]"]').val(imgmid2);
         $('#feature'+rownow+' .image'+rowgnow3+' input[name="filelinkcrop[]"]').val(filelink2);                                    
         $('#feature'+rownow+' .image'+rowgnow3+' input[name="widthcrop[]"]').val(width2);         
         $('#feature'+rownow+' .image'+rowgnow3+' input[name="heightcrop[]"]').val(height2);
      //   $.colorbox.close("User added succesfully"); 

          
          },
          function(filename,filelink,width,height,imgmid,indexnow){
            
            //$('#feature'+rownow+' .royalSlider  a.rsImg').eq((rowgnow3-1)).attr("href",filelink+'?t='+Math.floor((Math.random()*100000)+1));
          // $('#feature'+rownow+' .rsSlide  img').eq((rowgnow3-1)).attr("src",filelink+'?t='+Math.floor((Math.random()*100000)+1));
            $('#feature'+rownow+' .image'+rowgnow3+' input[name="filelink[]"]').val(filelink);
            $('#feature'+rownow+' .image'+rowgnow3+' input[name="imgmid[]"]').val(imgmid);           
            $('#feature'+rownow+' .image'+rowgnow3+' input[name="width[]"]').val(width);
            $('#feature'+rownow+' .image'+rowgnow3+' input[name="height[]"]').val(height);
            

          
          }
          ,
          rowgnow
          ,300
          ,300
   );
   
   });

   $("#feature"+rownow+' .inpTimeAddAct').datepicker( "destroy" ); 
   $("#feature"+rownow+' .inpTimeAddAct').timepicker();
   $("#feature"+rownow+' input[name="imgmid[]"]').val(imgmid);
   $("#feature"+rownow+' input[name="simgmid[]"]').val(simgmid);
   
   $("#feature"+rownow+' input[name="filelink[]"]').val(srcimg);
   $("#feature"+rownow+' input[name="filelinkcrop[]"]').val(srcimg);
   
   

}

var rownumberactnum=1;

function saveactivitypopup()
{
var code="";
if($('#featureactivity input[name="filelink[]"]').val())
{

if(activityidset)
{
var numsetact=activityidset;
}else
{

var numsetact=rowlanding;
code = '<div class="wrpInCell wrpInCellTrip w158 isactivity" id="wrpInCellTrip-'+numsetact+'" style="margin:1px">\n';


}

code += '<div class="ovlCellTrip w158"></div>\n';
code += '<img width="158" height="158" alt="img" src="'+$('#featureactivity input[name="filelinkcrop[]"]').val()+'" class="imgCell w158">\n';
code += '<div class="wrpTl wrpBtnEdtCell">\n';
code += '<div title="Remove" class="btnIco closeTl clBd3 bdBtm" onclick="removedataactivities('+numsetact+')">\n';
code += '<span class="ico icoCloseTl"></span>\n';
code += '</div>\n';
code += '<div title="Edit" class="btnIco edtCell" onclick="editactivity('+tripidrow+','+numsetact+')">\n';
code += '<span class="ico icoEdtCell"></span>\n';
code += '</div>\n';
code += '</div>\n';
code += '<div class="ldTtlCell ldTtlTrip fs05 clTxtCell cutTxt titleact">'+$('#featureactivity input[name="titleact[]"]').val()+'</div>\n';
code +='<textarea style="display:none" id="descriptionact-'+numsetact+'" name="descriptionact[]">'+$('#featureactivity .inpDesAddAct').val()+'</textarea>';

code +='<input name="imgmid[]" type="hidden" value="'+$('#featureactivity input[name="imgmid[]"]').val()+'">';
code +='<input name="simgmid[]" type="hidden" value="'+$('#featureactivity input[name="simgmid[]"]').val()+'">';


code += '<form class="inpTimeTrip">\n';
code += '<input type="text" placeholder="Click for insert time." alt="timeTrip-'+tripidrow+'-'+numsetact+'" value="'+$('#featureactivity .inpTimeAddAct').val()+'" class="timeTrip clTxtW fs01">\n';
code += '</form>\n';
code += '<div class="pointTrip classActity">\n';
if(activityidset)
{
var numsetdata=$("#wrpInCellTrip-"+numsetact+' .classActity .clTxtW.fs02').html();

}else
{
var numsetdata=rownumberactnum;
rownumberactnum++;
}
code += '<span class="clTxtW fs02">'+numsetdata+'</span>\n';
code += '</div>\n';
if(activityidset)
{
$("#wrpInCellTrip-"+numsetact).html(code);
}else
{





code += '</div>';

if($("#featuretriprow-"+tripidrow).hasClass('ispoi'))
{


}else
{
$("#featuretriprow-"+tripidrow+' .plgArea').remove();
$("#featuretriprow-"+tripidrow+' .desPlg.clTxt3.fs03').remove();
$("#featuretriprow-"+tripidrow).addClass('ispoi');
$("#featuretriprow-"+tripidrow+' .wrpOutAtcPlg').after( '<div class="wrpPlgAreaTrip Clearfix"><div class="plgAreaTrip"></div></div>' );

}
$("#featuretriprow-"+tripidrow+' .plgAreaTrip').append(code);

rowlanding++;

}
$( "#featuretriprow-"+tripidrow+' .timeTrip.clTxtW.fs01' ).datepicker( "destroy" ); 
$("#featuretriprow-"+tripidrow+' .timeTrip.clTxtW.fs01').timepicker(
   {onClose: function(dateText, inst) {

   
   var idtimetrip=$(this).attr("alt");
   var rownid=idtimetrip.split("-"); 
   changetimedata(rownid[1]);
   
    }
    
    });
changetimedata(tripidrow);

}
closepopupactivity();


}

function removedataactivities(rownowdata)
{
$("#wrpInCellTrip-"+rownowdata).remove();
var rowremove=1;
$.each($('.pointTrip.classActity .clTxtW.fs02'), function(index ) { 

           $(this).html(rowremove);
           rowremove++;
});
}

function removedatatrip(rownowdata)
{
$("#wrpInCellTrip-"+rownowdata).remove();
delete  setlandingproduct[rownowdata];
    var rowremove=0;
$.each($('.pointTrip.classpoint .clTxtW.fs02'), function(index ) { 

           $(this).html(pointData[rowremove]);
           rowremove++;
});
genmapdata();

}

function changecelldata(status)
{
setproductid=0;
setstatusnow=status;
pagemain=1;
$(".ovlPopGen.wrpPopAddPop .wrpInCellPopTrip").remove();
$(".ovlPopGen.wrpPopAddPop .spnSrcTg.tgCl").removeClass('clSp2');
$(".ovlPopGen.wrpPopAddPop #tripsstatus-"+status).addClass('clSp2');
setcelldata(status);

}
var pointData=new Array('A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z');
var iconBase = 'http://maps.google.com/mapfiles/kml/paddle/';
function genmapdata()
{
var genmappoint={};
var genpoint={};  
var genpointarr=new Array();
var rowgenmap=0;
$.each($('.pointTrip.classpoint'), function(index ) {

genmappoint[rowgenmap]=new google.maps.LatLng($(this).find('input[name="latsetrip[]"]').val(),$(this).find('input[name="lngsetrip[]"]').val())
;
genpointarr[rowgenmap]={latLng:[$(this).find('input[name="latsetrip[]"]').val(), $(this).find('input[name="lngsetrip[]"]').val()], data:$(this).find('span.clTxtW.fs02').html(),options:{icon: iconBase +pointData[rowgenmap]+'_maps.png'}};

genpoint[rowgenmap]={point:$(this).find('.clTxtW.fs02').html()};

rowgenmap++;





});

 
 //console.log(Object.keys(genmappoint).length);   
 
if(Object.keys(genmappoint).length>1)
{

  if(Object.keys(genmappoint).length>2)
  {
   var waypts=[];
   var rowwaypts=0;
  $.each(genmappoint, function(index, value) {
       
          if(rowwaypts!=0&&rowwaypts!=(Object.keys(genmappoint).length-1))
          {
          waypts.push(
          {
                location:new google.maps.LatLng(value.lat(),value.lng()),
                stopover:true
          }
          );
          }
          
          
          rowwaypts++;
                     
        //alert(index + ': ' + value);
        
        
        });
        
    var objset= {
        origin:genmappoint[0],
        destination:genmappoint[Object.keys(genmappoint).length-1],
        optimizeWaypoints: true,  
        avoidTolls:true,
        waypoints:waypts,
        avoidHighways:true,
        provideRouteAlternatives:true,
        travelMode: google.maps.DirectionsTravelMode.DRIVING
    };      
  
  
  }else
  {
  var objset= {
        origin:genmappoint[0],
        destination:genmappoint[Object.keys(genmappoint).length-1],
        optimizeWaypoints: true,  
        avoidTolls:true,
        avoidHighways:true,
        provideRouteAlternatives:true,
        travelMode: google.maps.DirectionsTravelMode.DRIVING
    };
  }

 $("#addform .itPlg.addMapPlg .plgArea").gmap3('destroy');
$("#addform .itPlg.addMapPlg .plgArea").gmap3({

  
   
  getroute:{
    options:objset,
    callback: function(results){

           
       
      if(results)
      {
 
      $(this).gmap3({
        map:{
          options:{
            zoom: 17, 
            center: genmappoint[0]
          }
        },
        directionsrenderer:{
          options:{
            directions:results
          }
        }
      });
      
      }else
      {   

      $(this).gmap3({
      map:{
          options:{
            zoom: 17, 
            center: genmappoint[0]
          }
        },
         marker:{
    values:genpointarr,
    options:{
      draggable: false
    }
      
      }
      
      });
    
      }
    
    }
  }
});
}else if(Object.keys(genmappoint).length==1)
{
$("#addform .itPlg.addMapPlg .plgArea").gmap3('destroy');
 $("#addform .itPlg.addMapPlg .plgArea").gmap3({
      map:{
          options:{
            zoom: 17, 
            center: genmappoint[0]
          }
        },
         marker:{
    values:genpointarr,
    options:{
      draggable: false
    }
      
      }
      
      });

}



}

function savepopuptrip()
{
if($( ".ovlPopGen.wrpPopAddPop .activeproduct .setproducthidden" ).length>0)
{

var code="";
var checkpoint=0;
var latsettrip=0;
var lngsettrip=0;
$( ".ovlPopGen.wrpPopAddPop .activeproduct .setproducthidden" ).each(function( index ) {

//console.log("1");

setlandingproduct[rowlanding]={};
setlandingproduct[rowlanding]=setproductidnow[$(this).val()];

code  = '<div class="wrpInCell wrpInCellTrip w158" id="wrpInCellTrip-'+rowlanding+'" style="margin:1px">\n';
code += '<div class="ovlCellTrip w158"></div>\n';
code += '<img width="158" height="158" alt="img" src="'+setlandingproduct[rowlanding].simg.newpath+'" class="imgCell w158">\n';
code += '<div class="wrpTl wrpBtnEdtCell">\n';
code += '<div title="Remove" class="btnIco closeTl" onclick="removedatatrip('+rowlanding+')">\n';
code += '<span class="ico icoCloseTl"></span>\n';
code += '</div>\n';
code += '</div>\n';
code += '<div class="ldTtlCell ldTtlTrip fs05 clTxtCell cutTxt">'+setlandingproduct[rowlanding].title+'</div>\n';
code += '<form class="inpTimeTrip">\n';
code += '<input type="text" alt="timeTrip-'+tripidrow+'-'+rowlanding+'"  placeholder="Click for insert time." class="timeTrip clTxtW fs01">\n';
code += '</form>\n';

if(setlandingproduct[rowlanding].plugins)
{
checkpoint=0;
$.each( setlandingproduct[rowlanding].plugins, function( key, value ) {

if(value.plugname=="map")
{

checkpoint=1;
latsettrip=value.lat;
lngsettrip=value.lng;


}

});


}

if(checkpoint==1)
{
code += '<div class="pointTrip classpoint">\n';

code += '<input type="hidden" value="'+latsettrip+'" name="latsetrip[]">';
code += '<input type="hidden" value="'+lngsettrip+'" name="lngsetrip[]">';
code += '<input type="hidden" value="'+$(this).val()+'" name="productidtrip[]">';


var lengthall=$('.plgAreaTrip .wrpInCell.wrpInCellTrip.w158 .pointTrip.classpoint').length;

code += '<span class="clTxtW fs02">'+pointData[lengthall]+'</span>\n';
code += '</div>\n';
}

code += '</div>';

if($("#featuretriprow-"+tripidrow).hasClass('ispoi'))
{


}else
{
$("#featuretriprow-"+tripidrow+' .plgArea').remove();
$("#featuretriprow-"+tripidrow+' .desPlg.clTxt3.fs03').remove();
$("#featuretriprow-"+tripidrow).addClass('ispoi');
$("#featuretriprow-"+tripidrow+' .wrpOutAtcPlg').after( '<div class="wrpPlgAreaTrip Clearfix"><div class="plgAreaTrip"></div></div>' );

}


$("#featuretriprow-"+tripidrow+' .plgAreaTrip').append(code);
rowlanding++;
$(".ovlPopGen.wrpPopAddPop").fadeOut();

});


$( "#featuretriprow-"+tripidrow+' .timeTrip.clTxtW.fs01' ).datepicker( "destroy" );
$("#featuretriprow-"+tripidrow+' .timeTrip.clTxtW.fs01').timepicker(
   {onClose: function(dateText, inst) {

   
   var idtimetrip=$(this).attr("alt");
   var rownid=idtimetrip.split("-"); 
   changetimedata(rownid[1]);
   
    }
    
    });


genmapdata();

}else
{
alertboxui("Please Select Data");

}




}

var setproductidnow={};
var setproductid;
var setlandingproduct=new Array();
var rowlanding=1;
function selectproduct(productid)
{
//setproductid=productid;
//$(".ovlPopGen.wrpPopAddPop .ovlCellTrip").removeClass('cellTripAtv');
if($(".ovlPopGen.wrpPopAddPop #setproduct-"+productid+" .ovlCellTrip").hasClass('cellTripAtv'))
{
$(".ovlPopGen.wrpPopAddPop #setproduct-"+productid+" .ovlCellTrip").removeClass('cellTripAtv');
$(".ovlPopGen.wrpPopAddPop #setproduct-"+productid).removeClass('activeproduct');


}else
{

$(".ovlPopGen.wrpPopAddPop #setproduct-"+productid+" .ovlCellTrip").addClass('cellTripAtv');
$(".ovlPopGen.wrpPopAddPop #setproduct-"+productid).addClass('activeproduct');

}



}

function saveformtrip(id,plugid)    
{
    var obj={};  
    var alltime,openhours,closehours,infomation,sameaddressprofile,address,countryid,proid,disid,tumid,state,code,samecontactprofile,facebook,twitter,googleplus,email,website,phone,fax,etc;
    
  samecontactprofile=$("#"+id+' input[name="samecontactprofile[]"]').is(':checked');
        if(samecontactprofile)
        {
        samecontactprofile=$("#"+id+' input[name="samecontactprofile[]"]').val();
        facebook="";
        twitter="";
        googleplus="";
        email="";
        website="";
        phone="";
        fax="";
        etc="";

        }else
        {
        samecontactprofile=0;
        facebook=$("#"+id+' input[name="facebook[]"]').val();
        twitter=$("#"+id+' input[name="twitter[]"]').val();
        googleplus=$("#"+id+' input[name="googleplus[]"]').val();
        email=$("#"+id+' input[name="email[]"]').val();
        website=$("#"+id+' input[name="website[]"]').val();
        phone=$("#"+id+' input[name="phone[]"]').val();
        fax=$("#"+id+' input[name="fax[]"]').val();
        etc=$("#"+id+' textarea[name="etc[]"]').val();



        }
        var objdata=new Array();
        var rowdataset=0;
        
        $.each($(".wrpInCell.wrpInCellTrip.w158"), function(index ) { 
        
        
        var t0=$(this).find('.timeTrip').val();
        if(t0!="")
        {
        var n0=$(this).find('.timeTrip').attr('alt').split("-");
        console.log(n0);
        var day0=$("#featuretriprow-"+n0[1]+' .rcmSizeAdd.fs01').html().split("/");
        if($(this).hasClass('isactivity'))
        {
        objdata[rowdataset]={isactivity:1,description:$(this).find('textarea[name="descriptionact[]"]').val(),title:$(this).find('.titleact').html(),simgmid:$(this).find('input[name="simgmid[]"]').val(),imgmid:$(this).find('input[name="imgmid[]"]').val(),dateset:day0[2]+'-'+day0[1]+'-'+day0[0],timeset:t0+':00',plandate:day0[2]+'-'+day0[1]+'-'+day0[0]+' '+t0+':00'};
        
        }else
        {
         
        objdata[rowdataset]={isactivity:0,sproductid:$(this).find('input[name="productidtrip[]"]').val(),dateset:day0[2]+'-'+day0[1]+'-'+day0[0],timeset:t0+':00',plandate:day0[2]+'-'+day0[1]+'-'+day0[0]+' '+t0+':00'};
        
        }
        rowdataset++;
        }
        
        });
        
        
        
        obj={plugid:plugid,samecontactprofile:samecontactprofile,facebook:facebook,twitter:twitter,googleplus:googleplus,email:email,website:website,phone:phone,fax:fax,etc:etc,objdata:objdata};
        return obj;

}

function  changetimedata(changerowid){


           var timeSet=new Array();
           var rowtime=0;
           var starttime=59;
           var lastiddata=0;
           $('#featuretriprow-'+changerowid+' .plgAreaTrip .timeTrip').each(function( index ) {
                     
                     if($(this).val())
                     {
                     
                      var timeVal=$(this).val()+':'+'00';
                     
                     
                     }else
                     {
                     
                      var timeVal='23:59:'+starttime;  
                      
                      starttime--;
                     
                     }
                     timeSet[rowtime]={};   
                      var setidattr=$(this).attr("alt");
                      var rownid=setidattr.split("-"); 
                      lastiddata= rownid[1];
                     var $cont =$("#featuretriprow-"+rownid[1]+" #wrpInCellTrip-"+rownid[2]).clone(true);
                     timeSet[rowtime]={timeset:timeVal,clonedata:$cont};
                     
                     rowtime++;
           
           });
           timeSet.sort(function(a, b) {
           return new Date( '1970/01/01 ' +a.timeset ) > new Date('1970/01/01 ' + b.timeset);
           });
           
           
            $("#featuretriprow-"+lastiddata+' .plgAreaTrip').html('');
           //  console.log(timeSet);
             $.each(timeSet, function(index, value) {
             
          //  console.log(value.clonedata);
        //   $("#featuretriprow-"+lastiddata+' .plgAreaTrip').append(value.clonedata);
           
           value.clonedata.appendTo($("#featuretriprow-"+lastiddata+' .plgAreaTrip'));

             
             });
          $( "#featuretriprow-"+lastiddata+' .timeTrip.clTxtW.fs01' ).datepicker( "destroy" ); 
           $("#featuretriprow-"+lastiddata+' .timeTrip.clTxtW.fs01').timepicker(
                   {
                   onClose: function(dateText, inst) {

                   
                   var idtimetrip=$(this).attr("alt");
                   var rownid=idtimetrip.split("-"); 
                   changetimedata(rownid[1]);
                   
                    }
    
            });  
            
            
            var rowremove=0;
$.each($('.pointTrip.classpoint .clTxtW.fs02'), function(index ) { 

           $(this).html(pointData[rowremove]);
           rowremove++;
});

var rowremove=1;
$.each($('.pointTrip.classActity .clTxtW.fs02'), function(index ) { 

           $(this).html(rowremove);
           rowremove++;
});
             
           genmapdata();
           
}

function loadmoretrip()
{
pagemain++;
setcelldata(setstatusnow);

}

function setcelldata(status)
{

if(status==1)
{
userid=myuserid;
fav=0;

}else
{
userid=0;
fav=myuserid;

}
$(".ovlPopGen.wrpPopAddPop .btnSeeMore").show();
//$.post()
var productxhr=$.get(serviceinfo+'getproduct', { page:pagemain,userid:userid,fav:fav,nopoi:1 }, function(data) { 
  
        if(data.error.response)
         {
          alertbox(data.error.error);
         
         }else
         {
         if(data.data.length>0)
         {
         
         $.each(data['data'], function(key, value) {
         setproductidnow[value.productid]=value;
         
            code = '<div class="wrpInCellPopTrip w128" id="setproduct-'+value.productid+'" onclick="selectproduct('+value.productid+')" >\n';
            code += '<div class="ovlCellTrip w128"></div>\n<input type="hidden" name="setproductid[]" class="setproducthidden" value="'+value.productid+'">';
            code += '<img width="128" height="128" alt="img" src="'+value.simg.newpath+'" class="imgCell w128">\n';
            code += '<div class="ldTtlCell ldTtlAddTrip fs05 clTxtCell">'+value.title+'</div>\n';
            code += '</div>';
            
            $(code).insertBefore('.ovlPopGen.wrpPopAddPop .btnSeeMore');
         });
         if(data.data.length<12)
         {
         $(".ovlPopGen.wrpPopAddPop .btnSeeMore").hide();
         
         }
         
         }else
         {
         $(".ovlPopGen.wrpPopAddPop .btnSeeMore").hide();
         
         
         }
         
         }
//console.log(data);

});


}

function getformtrip(dataplugin)
{
var code  = '<div class="wrpCtcInfo">'+"\n";
code += '<div class="wrpHdInfoGen">'+"\n";
code += '<h2 class="clTxt2 fs04">Contact</h2>'+"\n";
code += '</div>'+"\n";
code += '<table class="tbGenInfo tbCtcLd tbAddCtnt clTxt3 fs03">'+"\n";
code += '<tbody>'+"\n";
if(dataplugin.facebook.indexOf("facebook")!=-1)
{
var datafacebook=dataplugin.facebook;
if(dataplugin.facebook.indexOf("http://")!=-1)
{
    datafacebook="http://"+dataplugin.facebook;

}


code += '<tr>\n';
code += '<th>Facebook</th>\n';
code += '<td><a href="'+datafacebook+'" target="_blank">'+datafacebook+'</a></td>\n';
code += '</tr>\n';
}
if(dataplugin.twitter.indexOf("twitter")!=-1)
{
var datatwitter=dataplugin.twitter;
if(dataplugin.twitter.indexOf("http://")!=-1)
{
    datatwitter="http://"+dataplugin.twitter;

}
code += '<tr>\n';
code += '<th>Twitter</th>\n';
code += '<td><a href="'+datatwitter+'" target="_blank">'+datatwitter+'</a></td>\n';
code += '</tr>\n';
}
if(dataplugin.googleplus.indexOf("plus.google")!=-1)
{
var datatgoogleplus=dataplugin.googleplus;
if(dataplugin.googleplus.indexOf("http://")!=-1)
{
    datatgoogleplus="http://"+dataplugin.googleplus;

}

code += '<tr>\n';
code += '<th>Google+</th>\n';
code += '<td><a href="'+datatgoogleplus+'" target="_blank" >'+datatgoogleplus+'</a></td>\n';
code += '</tr>\n';

}
if(dataplugin.website)
{
if(ValidUrl(dataplugin.website))
{
code += '<tr>\n';
code += '<th>Website</th>\n';
code += '<td><a href="'+dataplugin.website+'" target="_blank" >'+dataplugin.website+'</a></td>\n';
code += '</tr>\n';
}
}
if(dataplugin.email)
{
if(validateEmail(dataplugin.email))
{
code += '<tr>\n';
code += '<th>Email</th>\n';
code += '<td>'+dataplugin.email+'</td>\n';
code += '</tr>\n';
}
}
if(dataplugin.phone)
{
code += '<tr>\n';
code += '<th>Phone</th>\n';
code += '<td>'+dataplugin.phone+'</td>\n';
code += '</tr>\n';
}
if(dataplugin.fax)
{
code += '<tr>\n';
code += '<th>Fax</th>\n';
code += '<td>'+dataplugin.fax+'</td>\n';
code += '</tr>\n';
}
if(dataplugin.etc)
{
code += '<tr>\n';
code += '<th>ETC</th>\n';
code += '<td>'+dataplugin.etc+'</td>\n';
code += '</tr>\n';
}
code += '</tbody>\n';
code += '</table>\n';

code += '</div>\n';


if(Object.keys(dataplugin.objdata).length>0)
{
var arraydata=dataplugin;

//code="";
code+= '<div class="ldIt wrpMapLd clBg4 w640 mapdataroute" >'
code+= '<div class="icoDefLd">'
code+= '<span class="ico icoMapDefLd"></span>'
code+= '<span>Map</span>'
code+= '</div>'
code+= '</div>';
var rowdata=1;
var rowdata2=1;
 var rowset=0;
 var alphabet = new Array('A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z');

$.each(arraydata['objdata'], function(keydata, valueobjdata) {

code+= '<div class="ldIt wrpMyTripLd clBg4 w640 clearfix">'
code+= '<div class="wrpAtcPlg">'
code+= '<div class="spnHdDayTrip clTxtW">'
code+= '<span class="fs03">Day '+rowdata+'</span><br>'
code+= '<span class="rcmAddGen fs01">'+keydata+'</span>'
code+= '</div>'
code+= '</div>'
code+= '<div class="wrpPlgAreaTrip">'
code+= '<div class="plgAreaTrip clearfix">'
if(Object.keys(valueobjdata).length>0)
{



 $.each(valueobjdata, function(keydata, valuedata2) {
 
 
 if(valuedata2['isactivity']!="0")
 {

code+= '<div class="wrpInCell wrpInCellTrip w158 wrpActCell" style="margin:1px" onclick="popupactivites(\''+valuedata2['title']+'\',\''+valuedata2['description']+'\')">'
code+= '<div class="ovlCellTrip w158"></div>'

code+= '<a href="javascript:void(0)"  class="galleryimage"><img height="158" title="'+valuedata2['img']['newpath']+'" width="158" alt="img" src="'+valuedata2['simg']['newpath']+'" class="imgCell w158"></a>'
code+= '<div class="ldTtlCell ldTtlTrip fs05 clTxtCell cutTxt">'+valuedata2['title']+'</div>'
code+= '<div class="timeTrip clTxtW fs01">'+valuedata2['plandate2']+'</div>'
code+= '<div class="pointTrip">'
code+= '<span class="clTxtW fs02">'+rowdata2+'</span>'
code+= '</div>'
code+= '</div>';

rowdata2++;
 
 }else
 {
 var lat="";
 var lng="";
 if( valuedata2['data'])
 {
 if(Object.keys(valuedata2['data']['plugins']).length>0)
 {
  $.each(valuedata2['data']['plugins'], function(keydata, valueplugins) {
  
 
 if(valueplugins['plugid']==5)
 {
 lat=valueplugins['lat'];
 lng=valueplugins['lng'];
 
 }
 
 });
 
 }
 
 
code+= '<div class="wrpInCell wrpInCellTrip w158 pointTripData" onclick="linkto(\''+baseinfo+'/'+valuedata2['data']['link']+'/'+valuedata2['data']['productid']+'\')" style="margin:1px">'
code+= '<div class="ovlCellTrip w158"></div>'
code+= '<a href="'+baseinfo+'/'+valuedata2['data']['link']+'/'+valuedata2['data']['productid']+'" target="_blank"><img height="158" width="158" alt="img" src="'+valuedata2['data']['simg']['newpath']+'" class="imgCell w158"></a>'
code+= '<div class="ldTtlCell ldTtlTrip fs05 clTxtCell cutTxt">'+valuedata2['data']['title']+'</div>'
code+= '<div class="timeTrip clTxtW fs01">'+valuedata2['plandate2']+'</div>'
code+= '<div class="pointTrip">'
code+= '<span class="clTxtW fs02">'+alphabet[rowset]+'</span>'
code+= '</div><input type="hidden" value="'+lng+'" name="lngset[]"><input type="hidden" value="'+lat+'" name="latset[]">'
code+= '</div>';
rowset++;
}
 
 }
 
 
 });
 }

code+= '</div>'


code+= '</div>'
code+= '</div>';


rowdata++;




});




}

return code;


}

